/*
 * info page
**/
<template>
<div class="fullx">
	<div class="main">
		<div class="head">
			<p class="desc">我已经邀请了 <span>{{tempDate.times}}</span> 个好友，</p>
			<p class="desc">获得 <span>{{tempDate.score}}</span> 积分</p>
			<i class="share"></i>
		</div>
		<div class="body" v-if="param.is_forge !== '1'">
			<p class="desc"><label for="">任务类型：</label>按 <span>转发完成人次</span> 赚取积分</p>
			<p class="desc"><label for="">预计收益：</label><span>{{param.personscore*21}}积分 ({{param.personscore*0.21}}元)</span></p>
			<p class="desc"><label for="">任务要求：</label></p>
			<p class="desc sm">1、点击右上角"..."分享给好友,每成功邀请一人参与,可获得{{param.personscore}}积分奖励。</p>
			<p class="desc sm">&nbsp;&nbsp;（<span>注：所邀请好友必须是首次参与,且完成该游戏才有效</span>）。</p>
			<p class="desc sm">2、如您第一次参与,点击下方 "进入游戏"”,完成该游戏,可获得{{param.personscore}}积分。</p>
			<p class="desc sm">3、温馨提示：每100积分可兑换1元红包,积分充足时,可到"积分商城"中兑换。</p>
		</div>
		<div class="body" v-if="param.is_forge === '1'">
			<p class="desc"><label for="">任务类型：</label>按 <span> 点击人次 </span> 赚取积分</p>
			<p class="desc"><label for="">预计收益：</label><span>{{param.personscore*21}}积分 ({{param.personscore*0.21}}元)</span></p>
			<p class="desc"><label for="">任务要求：</label></p>
			<p class="desc">1、点击“阅读文章”，可获得{{param.personscore}}积分奖励。</p>
			<p class="desc">2、点击右上角"..."分享给好友,邀请好友参与,可获得{{param.personscore}}积分奖励。</p>
			<p class="desc"><label for="">温馨提示：</label></p>
			<p class="desc">&nbsp;&nbsp;<span>热文需阅读10秒后，苹果机点击左上角返回键(安卓机点击手机物理返回键)，才能获取到相应积分哦~</span></p>
			<p class="desc">&nbsp;&nbsp;<span>请在该页中点击右上角“...”进行分享，在文章中分享无效哦~</span></p>
		</div>
		<div class="game-img">
			<div class="img-box">
				<img :src="param.icon" alt="" />
			</div>
			<p class="title">{{param.title}}</p>
		</div>
		<div class="btn-box">
			<a class="btn orange" v-tap="{methods:back}">返回首页</a>
			<a class="btn red" @click="gamestart(3)" v-if="param.is_forge !== '1'">进入游戏</a>
			<a class="btn red" @click="gamestart(5)" v-if="param.is_forge === '1'">阅读文章</a>
		</div>
	</div>
</div>
</template>
<script>
import {getPointTimes, gameRecord, clickRecord, shareRecord, getWZTInfo} from 'src/service/getData'
import {mapState} from 'vuex'
export default {
  data () {
    return {
      param: {},
      href: '',
      score: 16, // 积分基础值
      tempDate: {score: 0, times: 0}
    }
  },
  computed: {
    ...mapState([
      'I9RIA'
    ])
  },
  mounted () {
    setTimeout(() => {
      let query = this.$route.query
      if (query.personscore) localStorage.personscore = query.personscore
      this.initData({'is_forge': query.is_forge, 'appid': query.appid, 'url': query.url, 'wxlinkurl': query.wxlinkurl, 'title': query.title, 'icon': query.icon, 'personscore': localStorage.personscore}, query.wzid)
    }, 0)
  },
  methods: {
    async initData (elem, qwzid) {
      this.param = elem
      this.href = elem.url + '?wzid=' + qwzid + '&platform=wz'
      if (elem.is_forge === '1') {
        this.href = this.href + '&url=' + encodeURIComponent(elem.wxlinkurl)
        let res = await getWZTInfo(elem.appid)
        this.setShare(2, this.param.appid, res.data.desc)
      } else {
        this.setShare(1, this.param.appid)
      }
      let res = await getPointTimes(elem.appid)
      if (res.code === 0) {
        this.tempDate = res.data
      }
    },
    back () {
      this.setShare()
      this.$router.push('/index')
    },
    async gamestart (type) {
      await gameRecord(this.param.appid, type)
      window.location.href = this.href
    },
    setShare (type, appid, desc) {
      let sharelink = this.href + '&friendid=' + this.I9RIA.unionid
      this.I9RIA.shareConfig.title = this.param.title
      this.I9RIA.shareConfig.link = sharelink
      this.I9RIA.shareConfig.imgUrl = this.param.icon
      if (type === 2) {
        this.I9RIA.shareConfig.desc = desc // '读文章赢大奖，更多惊喜等你拿！和我一起玩赚吧~  '
        this.I9RIA.shareConfig.success = function () {
          clickRecord('index', 'sharewz')
          shareRecord(appid, sharelink)
        }
      } else if (type === 1) {
        this.I9RIA.shareConfig.success = function () {
          clickRecord('index', 'sharejf')
          shareRecord(appid, sharelink)
        }
      } else {
        this.I9RIA.shareConfig.title = '玩赚'
        this.I9RIA.shareConfig.link = location.origin
        this.I9RIA.shareConfig.imgUrl = location.origin + '/static/imgs/wi.jpg'
        this.I9RIA.shareConfig.desc = '玩游戏赢大奖，更多惊喜等你拿！和我一起玩赚吧~  '
        this.I9RIA.shareConfig.success = function () {}
      }
      console.log(this.I9RIA)
    }
  }
}
</script>
<style scoped>
	.fullx{z-index:999;position: fixed;z-index: 1001;overflow-y: auto;}
	.main{padding:0.11rem .15rem;background:#fff;}
	.head{background:#fbd400;padding:0.23rem 0.16rem;border-radius:8px;font-size:0.13rem;color: #333;position: relative;}
	.head .desc{line-height: 0.2rem;}
	.head .desc span{color:#ff5f00;}
	.share{background:url(../../assets/imgs/icon-share.png) no-repeat; background-size:100%;position: absolute; width: 0.6rem; height: 1.4rem; top: -0.04rem; right: 0.04rem;}
	.body{background:#efeff4;border-radius:8px;padding:0.11rem 0.13rem;margin-top: 0.1rem;}
	.body .desc{line-height:0.23rem;font-size: 0.1rem;color:#666;}
	.body .desc.sm{line-height: 0.15rem;}
	.body .desc label{color:#333;}
	.body .desc span{color:#fa7429;}
	.game-img{margin-top:0.36rem;text-align: center;}
	.game-img .img-box{width: 1.5rem; height: 1.5rem; margin: 0 auto; overflow: hidden; border-radius: 12px; box-shadow: 0 0 6px 0 #ccc; background: #ccc; position: relative; left: 0; top: 0;}
	.game-img .img-box img{height: 100%; width: auto; transform: translateX(-50%); position: absolute; left: 50%; top: 0;}
	.game-img .title{line-height:0.43rem;font-size: 0.13rem;color:#333;overflow: hidden;text-overflow: ellipsis;white-space: nowrap}
	.btn-box{margin-top:.04rem;text-align: center;}
	.btn-box .btn{width:1.1rem;line-height:0.35rem;font-size: 0.13rem;text-align: center;color:#fff;display: inline-block;border-radius:22px;margin:0 0.18rem;}
	.btn-box .btn.orange{background:#ffba00;}
	.btn-box .btn.red{background:#ff602a;}
</style>
